﻿using System;
using Soveryn.Commerce.API;
using Soveryn.Commerce.BaseClasses;

namespace Soveryn.Commerce.Controls
{

    /// <summary>
    /// This is the main class for doodad toolbar that is overlaid onto a doodad when an employee is in edit mode.
    /// </summary>
    public partial class DoodadToolbar : DoodadToolBarBaseClass
    {

        protected void Page_Load(object sender, EventArgs e)
        {

            if (IsPostBack)
                return;

            InsertHyperLink.Attributes.Add("onclick", "cmsInsertDoodad('" + ParentPage.EmployeeToken + "','" + PageBaseClass.WebsiteToken + "','" + doodad.DoodadInstanceID + "', " + ParentPage.Properties.PageID + ", '" + doodad.DoodadInstanceContainerID + "');");
            if (doodad.PageID != ParentPage.Properties.PageID)
            {
                EditHyperLink.CssClass = "cmsButton cmsButtonGrey cmsSmall";
                EditHyperLink.NavigateUrl = "/Page.aspx?PageID=" + doodad.PageID;
                EditHyperLink.Text = "view";
                UpLinkButton.Visible = false;
                DownLinkButton.Visible = false;

            }
            else
            {
                UpLinkButton.OnClientClick = "cmsDoodadMove('UP', '" + ParentPage.EmployeeToken + "','" + PageBaseClass.WebsiteToken + "', '" + doodad.ElementID + "', '" + doodad.DoodadInstanceID + "', " + ParentPage.Properties.PageID + ");return false;";
                DownLinkButton.OnClientClick = "cmsDoodadMove('DOWN', '" + ParentPage.EmployeeToken + "','" + PageBaseClass.WebsiteToken + "', '" + doodad.ElementID + "', '" + doodad.DoodadInstanceID + "', " + ParentPage.Properties.PageID + ");return false;";
                EditHyperLink.Attributes.Add("onclick", "cmsEditDoodad('" + ParentPage.EmployeeToken + "','" + PageBaseClass.WebsiteToken + "','" + doodad.DoodadInstanceID + "', " + ParentPage.Properties.PageID + ");");
            }

        }

    }
}